<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use cmf\controller\AdminBaseController;

class PlateController extends AdminBaseController
{
    // //查看资料
    // public function index()
    // {
    // }

    // //板块详情
    // public function plateDetails(Request $resquest)
    // {
    //     $parameter = $resquest->param();
    //     $id = $parameter['post_id'];
    //     //查找板块名

    //     //板块文章
    //     $category_id = Db::name('portal_category_post')->where(['post_id' => $id, 'status' => 1])->value('category_id');
    //     $res = Db::name('portal_category')->where('id', $category_id)->field('id,name')->find();
    //     $plate_whe = [
    //         'post_title' => $res['name'],
    //         'post_status' => 1,
    //         'delete_time' => 0,
    //         'is_top' => 1,
    //     ];
    //     $plate = Db::name('portal_post')->where($plate_whe)->field('id,thumbnail,post_excerpt,post_title')->find();
    //     //对应详情文章
    //     $post_res = Db::name('portal_post')->where('id', $id)->field('id,user_id,thumbnail,post_excerpt,post_content,post_title,post_hits,published_time')->find();
    //     $post_res['published_time'] = date('Y-m-d H:i:s', $post_res['published_time']);
    //     //发布人
    //     $user_name = Db::name('user')->where('id', $post_res['user_id'])->value('user_login');
    //     //上一条id
    //     $previous = Db::name('portal_category_post')->where(['category_id' => $category_id, 'status' => 1])->where('post_id', '<', $id)->field('post_id')->find();
    //     if (empty($previous))
    //     {
    //         $previous_id = '';}
    //     $previous_id = $previous['post_id'];
    //     //下一条id
    //     $next = Db::name('portal_category_post')->where(['category_id' => $category_id, 'status' => 1])->where('post_id', '>', $id)->field('post_id')->find();
    //     if (empty($next))
    //     {
    //         $next_id = '';}
    //     $next_id = $next['post_id'];
    //     $this->assign(['plate' => $plate, 'post_res' => $post_res, 'user_name' => $user_name, 'previous_id' => $previous_id, 'next_id' => $next_id]);
    //     return $this->fetch('plate_details');
    // }

    // //板块列表
    // public function plateList(Request $resquest)
    // {
    //     $parameter = $resquest->param();
    //     $post_id = $parameter['id'];
    //     //板块 分类名称,文章缩略图,文章简介

    //     //文章标题是板块名的文章
    //     $category_id = Db::name('portal_category_post')->where(['post_id' => $post_id, 'status' => 1])->value('category_id');
    //     $res = Db::name('portal_category')->where('id', $category_id)->field('id,name')->find();
    //     $plate_whe = [
    //         'id' => $post_id,
    //         'post_status' => 1,
    //         'is_top' => 1,
    //         'delete_time' => 0,
    //         'post_title' => $res['name'],
    //     ];
    //     $plate = Db::name('portal_post')->where($plate_whe)->field('id,thumbnail,post_excerpt,post_title')->find();
    //     //板块下的所有文章
    //     $post_id_res = Db::name('portal_category_post')->where(['category_id' => $res['id'], 'status' => 1])->field('post_id')->select();

    //     $post_res = array();
    //     foreach ($post_id_res as $k => $v)
    //     {
    //         $post_res[] = $v['post_id'];
    //     }

    //     $plate_res = Db::name('portal_post')->where('post_status', 1)->whereNotIn('post_title', $res['name'])->whereIn('id', $post_res)->field('id,thumbnail,post_excerpt,post_title,published_time')->paginate(5, false, ['query' => request()->param()]);

    //     //板块所有文章
    //     $this->assign(['plate_res' => $plate_res, 'plate' => $plate]);
    //     $this->assign(['plate_list' => $plate_res->render()]);
    //     return $this->fetch('plate_list');
    // }

    // //板块显示数据通用方法
    // public function xianshi($id)
    // {
    //     //板块 分类名称,文章缩略图,文章简介,
    //     $res = Db::name('portal_category')->where('id', $id)->field('id,name')->find();
    //     $post_id = Db::name('portal_category_post')->where(['category_id' => $res['id'], 'status' => 1])->value('post_id');
    //     $plate_whe = [
    //         'id' => $post_id,
    //         'post_title' => $res['name'],
    //         'post_status' => 1,
    //         'delete_time' => 0,
    //         'is_top' => 1,
    //     ];
    //     $plate = Db::name('portal_post')->where($plate_whe)->field('id,thumbnail,post_excerpt,post_title')->find();

    //     //所有项目的分类名称,文章缩略图,文章简介,
    //     $project = Db::name('portal_category')->where('parent_id', $res['id'])->field('id,name')->select();
    //     foreach ($project as $k => $v)
    //     {
    //         $project_id_res[] = $v['id'];
    //         $project_name_res[] = $v['name'];
    //     }
    //     $post_id_res = Db::name('portal_category_post')->whereIn('category_id', $project_id_res)->where('status', 1)->field('post_id')->select();
    //     $post_res = array();
    //     foreach ($post_id_res as $k => $v)
    //     {
    //         $post_res[] = $v['post_id'];
    //     }
    //     $whe = [
    //         'post_status' => 1,
    //         'delete_time' => 0,
    //         'is_top' => 1,
    //     ];
    //     $project_res = Db::name('portal_post')->whereIn('post_title', $project_name_res)->whereIn('id', $post_res)->where($whe)->field('id,thumbnail,post_excerpt,post_title')->select();
    //     $this->assign([
    //         //板块文章
    //         'plate' => $plate,
    //         //所有项目文章
    //         'project_res' => $project_res,
    //     ]);
    //     return $this->fetch('plate_index');
    // }

    // //齐创集团
    // public function qichuang()
    // {
    //     return $this->xianshi(1);
    // }

    // //宏泰板块
    // public function houda()
    // {
    //     return $this->xianshi(2);
    // }

    // //百分电子
    // public function baifen()
    // {
    //     return $this->xianshi(3);
    // }

    // //将相教育
    // public function jiangxiang()
    // {
    //     return $this->xianshi(4);
    // }

    // //爱辰防护
    // public function aichen()
    // {
    //     return $this->xianshi(5);
    // }

    // //十步科技
    // public function shibu()
    // {
    //     return $this->xianshi(6);
    // }

    // //见科智能
    // public function jianke()
    // {
    //     return $this->xianshi(7);
    // }

    // //京急便科技
    // public function jingji()
    // {
    //     return $this->xianshi(8);
    // }
}
